def maxSubArray(nums):
    if len(nums)==0:
        return 0
    else:
        sum_result = nums[0]
        current_value = nums[0]
        for i in range(1,len(nums)):
            if current_value<0:
                current_value = nums[i]
            else:
                current_value += nums[i]
            if current_value>sum_result:
                sum_result = current_value
        return sum_result
def main():
    a = [-2,1,-3,4,-1,2,1,-5,4]
    b = [-1]
    c = [-2,1]
    print(maxSubArray(a))
    print(maxSubArray(b))
    print(maxSubArray(c))
if __name__ == "__main__":
    main()